﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using SCFHS.Code;
using System.Security.Principal;

namespace SCFHS.Data
{
    public class User : System.Web.Security.MembershipUser, IPrincipal
    {
        public string sysUser = "SysUser";
        public int userID { get; set; }
        public string userName { get; set; }
        public string userPassword { get; set; }
        public string userProfileName { get; set; }
        public string userDefaultPage { get; set; }
        public bool isAdmin { get; set; }
        public bool isActive { get; set; }
        public string userRole { get; set; }

        private IIdentity id;
        public IIdentity Identity
        {
            get { return id; }
        }
        public User() { }

        public User(IIdentity Id, User user)
        {
            id = Id;
            userID = user.userID;
            userName = user.userName;
            userProfileName = user.userProfileName;
            userDefaultPage = user.userDefaultPage;
            isAdmin = user.isAdmin;
            userRole = user.userRole;
        }
        public bool IsInRole(string role)
        {
            if (this.userRole == ((int)UserRoles.All).ToString())
                return true;
            if (string.IsNullOrEmpty(this.userRole))
                return false;
            string[] userRoles = this.userRole.Split('/');
            return userRoles.Contains(role);
        }
        public bool IsInRole(UserRoles role)
        {
            return IsInRole(((int)role).ToString());
        }
    }

    public class Order
    {
        public int orderID { get; set; }
        public string orderNumber { get; set; }
        public string orderSubject { get; set; }
        public string orderClassificationNumber { get; set; }
        public bool isClosed { get; set; }
        public OrderStates orderState { get; set; }
        public DateTime CreationDate { get; set; }


        public string personName { get; set; }
        public int personBirthPlace { get; set; }
        public int personHighSchoolPlace { get; set; }
        public string personIDNumber { get; set; }
        public int personIDType { get; set; }
        public int personNationality { get; set; }
        public int personCurrentResidencePlace { get; set; }

        public string workPlaceName { get; set; }
        public int workPlaceType { get; set; }

        public DataTable orderSummeryPoints { get; set; }
        public DataTable orderRequestPoints { get; set; }
        public DataTable orderAttachmentPoints { get; set; }
        public DataTable orderAttachmentFiles { get; set; }

    }

    public class Instructions
    {
        public int orderID { get; set; }
        public int instructionID { get; set; }
        public string instructionAuthority { get; set; }
        public string instruction { get; set; }
        public string transferTo { get; set; }
        public string transferReason { get; set; }
        public DateTime SubmitTimestamp { get; set; }
        public bool isFinalInstruction { get; set; }

    }

    public class Followup
    {
        public int orderID { get; set; }
        public int followupID { get; set; }
        public string followupAuth { get; set; }
        public string followupSequenceNumber { get; set; }
        public DateTime followupTimestamp { get; set; }
        public string followupDiscription { get; set; }
        public string followupFollowerName { get; set; }
    }
}